package models;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import play.db.jpa.Model;

/**
 * Entity implementation class for Entity: Professor
 * 
 */
@Entity
public class Professor extends Model {
	
	public String graduacao;
	public String posGraduacao;
	public boolean ativo;

	@ManyToMany(cascade=CascadeType.ALL)
	public List<Curso> cursos;

	@OneToMany(mappedBy = "professor")
	public List<Turma> turmas;

	@OneToOne(cascade=CascadeType.ALL, optional=false)
	public Pessoa pessoa;
	
	@Override
	public int hashCode() {
		Long i = this.id;
		return 31 + ((i == null) ? 0 : i.hashCode());
	}
	
	@Override
	public boolean equals(Object o) {
		
		if (o instanceof Professor) {			
			Professor p = (Professor) o;			
			if (p.id == this.id && p.ativo == true)			
				return true;
		}		
		return false;
	}
}
